<?php

/**
*
* @package acp
* @copyright (c) 2009 kmklr72
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

/**
* @package acp
*/
class acp_social_network
{
	var $u_action;
	var $new_config = array();

	function main($id, $mode)
	{
		global $db, $user, $auth, $template;
		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
		global $sn;

		$sn_config = $sn->get_sn_config();
		$this->new_config = $sn_config;

		$action	= request_var('action', '');
		$submit = (isset($_POST['submit'])) ? true : false;

		$form_key = 'acp_social_network';
		add_form_key($form_key);

		/**
		*	Validation types are:
		*		string, int, bool,
		*		script_path (absolute path in url - beginning with / and no trailing slash),
		*		rpath (relative), rwpath (realtive, writable), path (relative path, but able to escape the root), wpath (writable)
		*/
		switch ($mode)
		{
			case 'settings':
				$display_vars = array(
					'title'	=> 'ACP_SN_SETTINGS',
					'vars'	=> array(
						'legend1'						=> 'ACP_SN_SETTINGS',
						'require_ip_check'				=> array('lang' => 'IP_CHECK_REGISTRATION',			'validate' => 'int', 'type' => 'custom', 'method' => 'select_ip_check_registration', 'explain' => true),
						'enable_social_network'			=> array('lang' => 'ENABLE_SOCIAL_NETWORK',			'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),

						'legend2'						=> 'ACP_SN_MOODS',
						'enable_moods'					=> array('lang' => 'ACP_SN_ENABLE_MOODS',			'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
						'mood_display_type'				=> array('lang' => 'ACP_SN_MOOD_DISPLAY_TYPE',		'validate' => 'int', 'type' => 'custom', 'method' => 'select_mood_display_type', 'explain' => true),
					)
				);

				$sn->acp_display_vars($display_vars, $form_key);
			break;

			default:
				trigger_error('NO_MODE', E_USER_ERROR);
			break;
		}

		if ($submit)
		{
			add_log('admin', 'LOG_CONFIG_' . strtoupper($mode));

			trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
		}

		$this->tpl_name = 'acp_social_network';
		$this->page_title = $display_vars['title'];
	}

	function select_mood_display_type($value, $key = '')
	{
		global $user, $config;

		$radio_ary = array(1 => 'MOOD_DISPLAY_TEXT', 2 => 'MOOD_DISPLAY_IMAGE');	

		return h_radio('config[mood_display_type]', $radio_ary, $value, $key);
	}
}

?>